<template>
	<wsPage title="问题反馈列表">
		<div slot="page_operate">
			<Button  @click="queryAll"><Icon type="refresh"></Icon><span>刷新</span></Button>
		</div>

		<!-- <Row class="tab-demo">
			<Col span="24">
			<Button :type="queryPanel.conditions.activeIndex == 0 ? 'primary' : ''" @click="showquery2">会员反馈(
                <span class="ws-text-red" v-text="count2"></span>)</Button>
			<Button :type="queryPanel.conditions.activeIndex == 1 ? 'primary' : ''" @click="showquery4">店铺反馈(
                <span class="ws-text-red" v-text="count4"></span>)</Button>
			</Col>
		</Row>	 -->

		<Row class="tab-demo">
			<Col span="24">
			<Button :class="{'ws-btn-active': activeIndex == 0}" @click="showMember">会员反馈</Button>
			<Button :class="{'ws-btn-active': activeIndex == 1}" @click="showTenant">商户反馈</Button>
			</Col>
		</Row>	

		<wsSmPanel :page="table1.page" @simple-query="query1" @page-change="query1"  v-if="showMemberFeedback">
			<div slot="list_data">
				<Table border :columns="table1.columns" :data="table1.data"></Table>
			</div>
		</wsSmPanel>
		
		<wsSmPanel :page="table2.page" @simple-query="query2" @page-change="query2"  v-if="showTenantFeedback">
			<div slot="list_data">
				<Table border :columns="table2.columns" :data="table2.data"></Table>
			</div>
		</wsSmPanel>
		

	</wsPage>
</template>

<script>
	import Util from '../../../common/util.js';
	import Common from '../../../common/common.js';
	export default {
		data() {
			return {
				activeIndex:0,
				showMemberFeedback:true,
				showTenantFeedback:false,
				queryForm: {},
				table1: {
					columns: [{
						title: '会员',
                        key: 'memberName',
                        width: 150,
                        align: 'center'
					},{
						title: '联系电话',
                        key: 'telephone',
                        width: 200,
                        align: 'center'
					},
					{
						title: '创建时间',
                        key: 'createDate',
                        width: 200,
                        align: 'center'
					},{
						title: '反馈内容',
                        key: 'content',
                        align: 'center'
					}],
					data: [],
					page: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					},
					selection: [], //选中
					loading: true
				},

				table2: {
					columns: [{
						title: '商户名',
                        key: 'tenantName',
                        width: 150,
                        align: 'center'
					},{
						title: '联系电话',
                        key: 'telephone',
                        width: 200,
                        align: 'center'
					},
					{
						title: '创建时间',
                        key: 'createDate',
                        width: 200,
                        align: 'center'
					},{
						title: '反馈内容',
                        key: 'content',
                        align: 'center'
					}],
					data: [],
					page: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					},
					selection: [], //选中
					loading: true
				},
			}
		},
		computed: {

		},
		mounted() {
			this.init();
		},
		methods: {
			init() {
				this.query1();
			},
			/**
			 * 刷新查询所有
			 */
			queryAll() {
				this.query1();
				this.query2();
			},

			/**
			 * 显示会员反馈
			 */
			showMember() {
				this.showMemberFeedback=true;
				this.showTenantFeedback=false;
				this.activeIndex=0;
			},

			/**
			 * 显示会员反馈
			 */
			showTenant() {
				this.activeIndex=1;
				this.query2();
				this.showMemberFeedback=false;
				this.showTenantFeedback=true;
			},
			/**
			 * 表单查询
			 */
			query1() {
				let pageSize = this.table1.page.pageSize;
				let pageNum = this.table1.page.pageNum;
				const _this = this;
				this.axios.get('/ws/ops/feedbacks/member?pageNum=' + pageNum + '&pageSize=' + pageSize, this.queryForm).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildPageData1(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 构建表格数据
			 */
			buildPageData1(data_) {
				this.table1.data = data_.list;
				this.table1.page.total = data_.total;
			},
			/**
			 * 表单查询
			 */
			query2() {
				let pageSize = this.table2.page.pageSize;
				let pageNum = this.table2.page.pageNum;
				const _this = this;
				this.axios.get('/ws/ops/feedbacks/tenant?pageNum=' + pageNum + '&pageSize=' + pageSize, this.queryForm).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildPageData2(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 构建表格数据
			 */
			buildPageData2(data_) {
				this.table2.data = data_.list;
				this.table2.page.total = data_.total;
			},
		}
	}
</script>

<style scoped>
	.ws-form-select {
		width: 162px;
	}
</style>